/**
 * 部门数据
 */	
    layui.config({
        base: ctxPath+'/lib/layui/lay/modules/'
/*
 * /springboot-boot/src/main/webapp/static
 */    }).extend({   // 引用第三方的插件
        treetable: 'treetable-lay/treetable'
    }).use(['layer', 'table', 'treetable','form'], function () {
        var $ = layui.jquery;
        var table = layui.table;
        var layer = parent.layer === undefined ? layui.layer : top.layer;
        var treetable = layui.treetable;
        var form = layui.form;
        var treeParams = {
                treeColIndex: 1,
                treeSpid: 0,   // 树数据最顶级的父类 如果支持搜索条件的话，得改变这里的数据或者查询条件的数据
                treeIdName: 'id',
                treePidName: 'pid',
                treeDefaultClose: true,
                treeLinkage: false,
                elem: '#list',
                url:ctxPath+ '/tSystemMenu/tSystemMenuList' ,
                page: false,
                cols: [[
                    {type: 'numbers'},
							{field: 'name', title: '菜单名称', align:"center"},
							{field: 'menuIcon', title: 'menuIcon', align:"center"},
							{field: 'reqUrl', title: '请求url', align:"center"},
				            {field: 'createTime', title: '创建时间', align:'center', align:'center'},
		            {title: '操作', width:170, fixed:"right",align:"center",templet:function(d){
		            	var html="";
		            	if($.shiro.hasPermission('/tSystemMenu/toTSystemMenuUpdate')){
		            		html+=	'<a class="layui-btn layui-btn-xs boot-layer " boot-title="修改" boot-url="'+ctxPath+'/tSystemMenu/toTSystemMenuUpdate?id='+d.id+'">编辑</a>';
		            	}
		            	if($.shiro.hasPermission('/tSystemMenu/tSystemMenuDelete')){
		            		html+=	'<a class="layui-btn layui-btn-xs layui-btn-danger boot-ajax " boot-title="确认要删除吗" boot-url="'+ctxPath+'/tSystemMenu/tSystemMenuDelete?id='+d.id+'"  >删除</a> ';
		            	}
		            	return html;
		            }}
                ]]
            }
       
        // 展开全部
        $('#btn-expand').click(function () {
            treetable.expandAll('#list');
        });
        // 收缩全部
        $('#btn-fold').click(function () {
            treetable.foldAll('#list');
        });
        // 根据条件搜索Tree
        $('#search_btn').click(function () {
        	treeParams.queryTree=true; //开启查询tree参数
        	treeParams.data=null; //重新设置数据为NULL关掉缓存
        	treeParams.url =ctxPath+ '/tSystemMenu/tSystemMenuList?'+$(this).closest("form").serialize();
        	treetable.render(treeParams);
        });
        $('#search_btn').click();
        //如果存在id  元素 就进行刷新  为了解决添加，会自动加载的问题
        if(!_.isEmpty($("#list"))){
        	 treetable.render(treeParams);
        }
    });